package com.pkk.penguin.frame.know.java.jvm.classload;

/**
 * @description: 类的初始化过程
 * @author: peikunkun
 * @create: 2020-02-19 22:17
 **/
public class ClassInit_1 {


  private static int simple1 = 1;

  private static final int simple2 = 2;


  static {
    simple1 = 4;
    //System.out.println(simple1);
    simple3 = 5;
    //此处只可以引用,但是不能直接输出,因为后面定义的缘故
    //System.out.println(simple3);
  }


  private static int simple3 = 3;


  public static void main(String[] args) {
    System.out.println("探索类的执行过程,当我们类中存在静态变量初始化或者静态代码块时,在编译的时候会为我们生成方法<clinit>(),用于整合静态变量的初始化执行,"
        + "其次编译还默认生成<init>构造器方法(可重载),用于实例化时执行");
    System.out.println(simple1);
    System.out.println(simple2);
    System.out.println(simple3);
  }


}
